package com.app.utils;

import com.app.common.Result;
import com.app.model.AdminUserModel;
import com.app.server.AdminUserService;
import com.app.server.impl.AdminUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

public class AdminUtil {


    public static Result<Object> CheckLoginInfo(String token){
        AdminUserService adminUserService =new AdminUserServiceImpl();
        if (token == null) {
            return Result.error(405, "token不存在");
        }
        String userId = TokenUtils.verify(token);
        if (userId.equals("false")) {
            return Result.error(405, "token已过期");
        }

        AdminUserModel user = adminUserService.getById(Integer.parseInt(userId));
        if (user == null) {
            return Result.error(406, "用户不存在");
        }
        return null;
    }
}
